home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / football / user / flipschedule.rexx < prev    next >
OS/2 REXX Batch file  |  1999-02-03  |  3KB  |  87 lines

  1. /* ***********************************************************************
  2.  
  3.    FLIPSCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------
  5.                    Copyright  Mark Naughton 1996
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       270996   First release.
  11.  1.1       121196   Added to Football as a callable component. Amended for
  12.                     different leagues. Removed messages.
  13.            131196   Added checks for files - if not found, exits without
  14.                     a message.
  15.            241196   Now called as an External script. Added info messages.
  16.  
  17. **************************************************************************
  18.  
  19. Procedure
  20. ---------
  21.  
  22. 1. Check files exist. Open Learn file and output file.
  23. 2. Read from Learn, then flip the home and away teams, reset the scores
  24.    to 'not_played' and then write to output file.
  25. 3. Close files and end. When finished this file can then be printed off
  26.    and it'll make entering data into GAMEPLAY much easier.
  27.  
  28. ************************************************************************** */
  29. ARG league_file
  30.  
  31. league_file  = "Data/" || league_file
  32. version      = 1
  33. input_file   = '.sflearn'
  34. output_file  = '.sflisting'
  35. not_played   = '__   __'
  36. separator    = '*'
  37.  
  38. if exists(league_file || input_file) = 0 then exit
  39.  
  40. say "This program will flip the schedule and display all the"
  41. say "alternate fixtures. If a schedule is not known, then it"
  42. say "is 'learnt' using 'Enter Scores'. When the season is halfway"
  43. say "through, this program can be run to print the next half"
  44. say "of the seasons fixtures. A file '"league_file || output_file"'"
  45. say "produced and can then be printed."
  46. say
  47. say "Working..."
  48. say
  49.  
  50. if open(datafile,league_file || input_file,'r') then do
  51.    if open(datafile2,league_file || output_file,'w') then do
  52.       do while ~eof(datafile)
  53.          line = readln(datafile)
  54.          if pos(separator,line) = 0 then do
  55.             home = substr(line,1,30)
  56.             away = substr(line,41,30)
  57.             line = overlay(away,line,1)
  58.             line = overlay(home,line,41)
  59.             if pos(not_played,line) = 0  & words(line) > 0 then
  60.                line = overlay(not_played,line,32)
  61.          end
  62.          writeln(datafile2,line)
  63.       end
  64.       close(datafile2)
  65.       say "Schedule has been 'flipped'."
  66.       say "The file '"league_file || output_file"' can now be printed."
  67.       say
  68.       say
  69.    end
  70.    else do
  71.       say
  72.       say "ERROR :    (FlipSchedule)"
  73.       say
  74.       say "Cannot open '"league_file || output_file"' for writing."
  75.       close(datafile)
  76.       exit
  77.    end
  78.    close(datafile)
  79. end
  80. else do
  81.    say
  82.    say "ERROR :    (FlipSchedule)"
  83.    say
  84.    say "Cannot open '"league_file || input_file"' for reading."
  85. end
  86.  
  87. exit